#include <iostream>
#include <string>
#include <signal.h>

#include "sock.hpp"

void usage(std::string proc)
{
  std::cout << "usage:\n\t" << proc << ": need port" << std::endl;
}


int main(int argc, char* argv[])
{
  if (argc != 2)
  {
    usage(argv[0]);
    return 1;
  }

  uint16_t port = atoi(argv[1]);
  int listen_sock = Sock::Socket();
  Sock::Bind(listen_sock, port);
  int back_log = 5;
  Sock::Listen(listen_sock, back_log);

  signal(SIGCHLD, SIG_IGN);

  while(true)
  {
    int new_sock = Sock::Accept(listen_sock);
  }
  return 0;
}
